home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue40 / Alfresco / UTstDate.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-11-01  |  1.4 KB  |  70 lines

  1. unit UTstDate;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Label1: TLabel;
  12.     ComboBox1: TComboBox;
  13.     ComboBox2: TComboBox;
  14.     ComboBox3: TComboBox;
  15.     ComboBox4: TComboBox;
  16.     Label2: TLabel;
  17.     Button1: TButton;
  18.     Label3: TLabel;
  19.     Label4: TLabel;
  20.     procedure FormCreate(Sender: TObject);
  21.     procedure Button1Click(Sender: TObject);
  22.   private
  23.     { Private declarations }
  24.   public
  25.     { Public declarations }
  26.   end;
  27.  
  28. var
  29.   Form1: TForm1;
  30.  
  31. implementation
  32.  
  33. uses
  34.   AACDate;
  35.  
  36. {$R *.DFM}
  37.  
  38. procedure TForm1.FormCreate(Sender: TObject);
  39. begin
  40.   ComboBox1.ItemIndex := 0;
  41.   ComboBox2.ItemIndex := 0;
  42.   ComboBox3.ItemIndex := 0;
  43.   ComboBox4.ItemIndex := 0;
  44. end;
  45.  
  46. procedure TForm1.Button1Click(Sender: TObject);
  47. var
  48.   Day   : integer;
  49.   Month : integer;
  50.   Year  : integer;
  51.   WhichOne : integer;
  52.   Date     : TDateTime;
  53.   Week     : integer;
  54. begin
  55.   Day := ComboBox2.ItemIndex + 1;
  56.   Month := ComboBox1.ItemIndex + 1;
  57.   Year := ComboBox4.ItemIndex + 1980;
  58.   WhichOne := ComboBox3.ItemIndex + 1;
  59.   Date := GetDateForDayOfMonth(WhichOne, Day, Month, Year);
  60.   if Date = 0.0 then
  61.     Label3.Caption := 'no such day'
  62.   else begin
  63.     Label3.Caption := DateToStr(Date);
  64.     GetISODate(Date, Year, Week, Day);
  65.     Label4.Caption := Format('Week %d, Day %d, %d', [Week, Day, Year]); 
  66.   end;
  67. end;
  68.  
  69. end.
  70.